<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-07-03 16:24
 *
 * Version: 2.0
 */

namespace App\Modules\Order\Criterias;


use App\Models\Order;
use App\Modules\Order\Validators\OrderValidator;
use Flower\Core\Repository\Contracts\CriteriaInterface;
use Flower\Core\Repository\Contracts\RepositoryInterface;
use Illuminate\Support\Facades\DB;

class orderTodayCriteria implements CriteriaInterface
{
	private $data;
	public function model()
	{
		return Order::class;
	}

	public function validator()
	{
		return OrderValidator::class;
	}

	public function __construct($data)
	{
		$this->data = $data;
	}

	public function apply($model, RepositoryInterface $repository)
	{
		$map = [
			'store_id' => $this->data['store_id'],
			'status' => config('constant.orderStatus.done')
		];
		return $model->whereDate('created_at',$this->data['date'])->where($map);
	}
}